package com.bazinga.contact.view;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.bazinga.contact.controller.JobDetailsManager;
import com.bazinga.contact.model.AllCreatedJobs;
import com.bazinga.contact.model.JobDetails;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class CreatedJobsAction extends ActionSupport implements SessionAware{


	private static final long serialVersionUID = 5650923110652312524L;
	
	private final String dbServer = "127.0.0.1";
	private Map<String, Object> session;
	
	private String userid = null;
	
	private List<JobDetails> joblist;

	private AllCreatedJobs allJobs; 
	
	private JobDetailsManager linkController;
	
	public CreatedJobsAction(){
		linkController = new JobDetailsManager();
	}
	
	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
		
	}

	public String execute() {
		this.session = ActionContext.getContext().getSession();
		if(session.containsKey("userid")) {
			userid = (String) session.get("userid");
		}
		
		joblist = linkController.getByUserId(new Long(userid));
		
		return "success";
	}

	public AllCreatedJobs getAllJobs() {
		return allJobs;
	}

	public void setAllJobs(AllCreatedJobs allJobs) {
		this.allJobs = allJobs;
	}

	public String getUserid() {
		return userid;
	}

	public void setUserid(String userid) {
		this.userid = userid;
	}

	public List<JobDetails> getJoblist() {
		return joblist;
	}

	public void setJoblist(List<JobDetails> joblist) {
		this.joblist = joblist;
	}

	

}
